package com.woniuxy02;

import java.util.*;

/**
 * @author 作者
 * @create 2025-11-10 16:12
 */
public class Test02 {
    public static void main(String[] args) {
        Student s11=new Student(1,"zs",11);
        Student s12=new Student(2,"ws",12);
        HashMap<String,Student> class1=new HashMap<>();
        class1.put("s11",s11);
        class1.put("s12",s12);

        Student s21=new Student(1,"ww",13);
        Student s22=new Student(2,"zl",15);
        HashMap<String,Student> class2=new HashMap<>();
        class2.put("s21",s21);
        class2.put("s22",s22);

        ArrayList<HashMap<String,Student>> school=new ArrayList<>();
        school.add(class1);
        school.add(class2);

        //遍历School
        for(HashMap<String,Student>  myclass : school){
            System.out.println("进入一个班");
            Set<Map.Entry<String,Student>> entries =myclass.entrySet();
            for( Map.Entry<String,Student> entry :entries){
                System.out.println(entry.getKey());
                System.out.println(entry.getValue());
            }
        }


    }

    private static void test01() {
        // 一班有两个学生
        Student s11=new Student(1,"zs",11);
        Student s12=new Student(2,"ws",12);
        //班级：学生的集合
        ArrayList<Student> class1=new ArrayList<>();
        class1.add(s11);
        class1.add(s12);

        Student s21=new Student(1,"ww",13);
        Student s22=new Student(2,"zl",15);
        ArrayList<Student> class2=new ArrayList<>();
        class2.add(s21);
        class2.add(s22);

        //学校：班级的集合
        ArrayList<ArrayList<Student>> school=new ArrayList<>();
        school.add(class1);
        school.add(class2);

        //遍历school
        for(ArrayList<Student> myclass : school){
            System.out.println("进入一个班");
            for( Student student : myclass) {
                System.out.println(student);
            }
        }
    }
}
